<template>
  <el-dialog
    title="操作记录"
    :close-on-click-modal="false"
    append-to-body
    v-model="is_show"
    :before-close="beforeClose"
    width="850px"
    class="history_page"
  >
    <el-table v-loading="loading" :data="tableData" stripe>
      <el-table-column label="序号" type="index" width="50" />
      <el-table-column label="操作时间" prop="operationTime" width="200" />
      <el-table-column label="操作人员" prop="operator" />
      <el-table-column label="操作类型" prop="operationType" />
      <el-table-column
        label="字段名"
        prop="fieldName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="旧字段值"
        prop="oldValue"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="新字段值"
        prop="newValue"
        :show-overflow-tooltip="true"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </el-dialog>
</template>
<script setup name="historyDetail">
import { getOperaList } from '@/api/rsgl/ygda'
import { ref, reactive, computed, getCurrentInstance } from 'vue'

const { proxy } = getCurrentInstance()
const is_show = computed(() => {
  return true
})
const loading = ref(false)
const props = defineProps({
  rowId: {
    type: String
  }
})
const data = reactive({
  tableData: [],
  // 总条数
  total: 0,
  // 查询参数
  queryParams: {
    pageNum: 1,
    pageSize: 10
  },
  //文档性质
  documentNatureList: [
    {
      id: 'tb_employee_study',
      name: '学习经历'
    },
    {
      id: 'tb_employee_contract',
      name: '合同信息'
    },
    {
      id: 'tb_employee_certificate',
      name: '取得证书'
    },
    {
      id: 'tb_employee_work',
      name: '工作经历'
    }
  ]
})
const { tableData, documentNatureList, total, queryParams } = toRefs(data)

function beforeClose() {
  proxy.$emit('closeDialog')
}
async function init() {
  getList()
}
init()

function getList() {
  loading.value = true
  console.log('queryParams.pageNum', queryParams.value.pageNum)
  getOperaList({
    pageNum: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    parentIdKey: props.rowId,
    tableName: 'tb_employee'
  }).then(res => {
    if (res.code == 200) {
      console.log('res===', res)
      tableData.value = res.rows
      total.value = res.total
      loading.value = false
    }
  })
}
</script>
<style lang="scss" scoped>
.history_page {
  display: block;
}
</style>
